export {};

function sum(a: number, b: number): number {
    return a + b;
}

console.log(sum(1, 2));

// age 为可选参数
function getPerson(name: string, age?: number): string {
    age = age == undefined ? 0 : age;
    return `name:${name}, age: ${age}`;
}
console.log(getPerson("xue"));

// 默认参数
function getPerson1(name: string, age: number = 1): string {
    return `name:${name}, age: ${age}`;
}
console.log(getPerson1("xue"));

// 联合类型
function parseNum(num: string | number) {
    console.log(typeof num);
}
parseNum("1");
parseNum(2);

// 任意类型
function parseNum1(num: any) {
    console.log(typeof num);
}
parseNum1("1");
parseNum1(2.1);
parseNum1(2);
